home *** CD-ROM | disk | FTP | other *** search
- { %filename% -- document methods }
- { Created %date% %time% by AppMaker }
-
- { We recommend that you not modify this module and instead modify }
- { its subclass, %Appname%Doc. The 'z' prefix on this module marks% %}
- { a module which is likely to be regenerated by AppMaker after you }
- { make changes to the user interface. The modules without the 'z' }
- { prefix will not be regenerated by AppMaker unless you delete them. }
- { Using a separate subclass to override the AppMaker-generated code }
- { lets you regenerate code without losing your hand-coded changes. }
-
- Unit %unitname%;
- Interface
-
- Uses
- TCL,
- AMCL,
- z%AppName%Intf,
- %AppName%Intf,
- ResourceDefs;
-
- {----------}
- Implementation
-
- {----------}
- Procedure Z%Appname%Doc.I%Appname%Doc (aSupervisor: CApplication;
- printable: Boolean);
- Begin
- IDocument (aSupervisor, printable);
- %for each window gen initNil%
- End; {I%Appname%Doc}
-
- %if multiWindow%
- {----------}
- Procedure Z%Appname%Doc.Free;
- Begin
- %for each window gen free%
- itsWindow := nil;
- inherited Free;
- End; {Free}
-
- {----------}
- Procedure Z%Appname%Doc.ActivateWind (theWindow: CWindow);
- Begin
- itsWindow := theWindow;
- inherited ActivateWind (theWindow);
- End; {ActivateWind}
-
- {----------}
- Procedure Z%Appname%Doc.DeactivateWind (theWindow: CWindow);
- Begin
- itsWindow := theWindow;
- inherited DeactivateWind (theWindow);
- End; {DeactivateWind}
-
- {----------}
- Procedure Z%Appname%Doc.CloseWind (theWindow: CWindow);
- Begin
- %for each window gen CloseWind%
- end;
- End; {CloseWind}
-
- %endif%
- {----------}
- Function Z%Appname%Doc.ReadData (var theData: Handle): Boolean;
- Begin
- ReadData := false;
- End; {ReadData}
-
- {----------}
- Procedure Z%Appname%Doc.WriteData;
- Begin
- { application-specific write data to itsFile }
- End; {WriteData}
-
- {----------}
- Procedure Z%Appname%Doc.NewFile;
- Begin
- BuildWindows;
- itsWindow.Select;
- End; {NewFile}
-
- {----------}
- Procedure Z%Appname%Doc.OpenFile (macSFReply: SFReply);
- var
- theFile: CDataFile;
- theData: Handle;
- theName: Str255;
- theError: OSErr;
- Begin
- New (theFile);
- with theFile do begin
- IDataFile;
- SFSpecify (macSFReply);
- end; {with}
-
- itsFile := theFile;
- theError := theFile.Open (fsRdWrPerm);
- if not gError.CheckOSError (theError) then begin
- Free;
- Exit (OpenFile);
- end;
-
- if not ReadData (theData) then begin
- Free;
- Exit (OpenFile);
- end;
-
- BuildWindows;
- DisposHandle (theData);
- itsFile.GetName (theName);
- itsWindow.SetTitle (theName);
- itsWindow.Select;
- End; {OpenFile}
-
- {----------}
- Procedure Z%Appname%Doc.BuildWindows;
- Begin
- %for each window gen create%
- End; {BuildWindows}
-
- {----------}
- Function Z%Appname%Doc.DoSave: Boolean;
- Begin
- if itsFile = nil then begin
- DoSave := DoSaveFileAs;
- end else begin
- WriteData;
- dirty := false;
- gBartender.DisableCmd (cmdSave);
- DoSave := true;
- end;
- End; {DoSave}
-
- {----------}
- Function Z%Appname%Doc.DoSaveAs (macSFReply: SFReply): Boolean;
- var
- theFile: CDataFile;
- theError: OSErr;
- Begin
- if itsFile <> nil then begin
- itsFile.Free;
- end;
- New (theFile);
- theFile.IDataFile;
- theFile.SFSpecify (macSFReply);
- itsFile := theFile;
-
- theError := theFile.CreateNew (gSignature, 'TEXT');
- theError := theFile.Open (fsRdWrPerm);
-
- itsWindow.SetTitle (macSFReply.fName);
- DoSaveAs := DoSave;
- End; {DoSaveAs}
-
- {----------}
- Procedure Z%Appname%Doc.DoCommand (theCommand: longint);
- Begin
- case theCommand of
- cmdClose:
- CloseWind (itsWindow);
- otherwise
- inherited DoCommand (theCommand);
- end; {case}
- End; {DoCommand}
-
- End. {%unitname%}
-